import { View } from "@tarojs/components";
import CustomLayout from "@/components/CustomLayout";
import Taro from "@tarojs/taro";
import { Avatar, Image } from "@nutui/nutui-react-taro";
import { Setting } from "@nutui/icons-react-taro";
import { goToPage } from "@/utils/common";
import { useGlobalData } from "@/store/app";
import ChatTask from "@/components/ChatTask";
import "./index.scss";

function Index() {
  const { useInfo, setUseInfo } = useGlobalData();

  const getUseInfo = () => {
    // 获取用户信息
    Taro.getUserProfile({
      desc: "用于完善会员资料", // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
      success: (res) => {
        console.log(res);
        setUseInfo({ ...res?.userInfo });
      },
    });
  };

  return (
    <>
      <CustomLayout.Header />
      <CustomLayout.Body className="personal_page">
        <View className="personal_page_header">
          <Avatar
            className="personal_page_header_avatar"
            src={`${useInfo?.avatarUrl || ""}`}
            shape="round"
            onClick={() => getUseInfo()}
          />
          <View className="personal_page_header_info">
            <View className="personal_page_header_info_name">用户名称</View>
            <View className="personal_page_header_info_firm">企业名称名称</View>
          </View>
          <Setting
            size="18px"
            className="personal_page_header_set"
            onClick={() => goToPage("/packageA/pages/setting/index")}
          />
        </View>
        <View className="personal_page_task">
          <ChatTask />
        </View>
      </CustomLayout.Body>
    </>
  );
}

export default Index;
